var layer;
var $;
var element;
var form;
var laydate;
var table;
var upload;
layui.use(['element','layer','laydate','form','table','upload'], function(){
    layer = layui.layer;
    $ = layui.jquery;
    element = layui.element;
    form = layui.form;
    laydate = layui.laydate;
    table = layui.table;
    upload = layui.upload;
    laydate.render({
        elem: '#birthDate', //指定元素
        type: 'datetime',
        trigger: 'click' //时间时间为点击事件
    });
    load();
})
function load(){
    var avatarUrl = $("input[name=avatarUrl]").val();
    $(".img_title").attr("src",avatarUrl);
    //点击上传图片
    $("#updimga").on("click",function(){
        $("#imgbut").click();
    });
    //图片上传
    var uploadInst = upload.render({
        elem: '#imgbut',
        url: '/personnel/addBackUserImg',//改成您自己的上传接口,
        accept:'images',
        ext: 'jpg|png|bmp|jpeg',
        size: 4096, //限制文件大小单位 KB
        before: function (obj) {
            var userId = $("input[name=userId]").val();
            this.data={'userId':userId}
            //预读本地文件示例
            obj.preview(function (index, file, result) {
                if(file.size >1024*1024*4) {
                    layer.msg('文件大小不得超过4MB', {icon: 2});//layui弹出层，icon: 5，时，是一个嘴角向下的脸
                }else{
                    $('.img_title').attr('src', result); //图片链接(base64)
                    $("input[name=avatarUrl]").val(result);
                }
            });
        }, done: function (res) {
            layer.msg('添加成功', {icon: 1});
            parent.selIndexUserTab();
            //上传成功的一些操作
        }
    });
    //悬浮提示
    $(".dept_a").mouseover(function() {
        layer.tips('点击选取部门', this, {
            tips:[1, '#FFB800'], time:1000
        });
    });
    //悬浮提示
    $("#updimga").mouseover(function() {
        layer.tips('图片大小限制于4MB', this, {
            tips:[1, '#FF5722'], time:1000
        });
    });
}
/**
 *  点击编辑部门
 * */
function updDept(){
    layer.open({
        type:2,//弹出层的类型
        title:"编辑部门信息",
        area:['565px','355px'],//弹出层大小
        shade:0,//设置遮罩
        offset:'auto',//设置遮罩的位置
        //弹出层内容
        content : "/personnel/layer/PerBackstageUser_layer_upd_Dept.html",
        success:function(layero,index){
        }
    })
}